#ifndef __PWM_H__
#define __PWM_H__

void hal_pwm_init(void);

typedef struct {
   volatile unsigned int TCFG0;
   volatile unsigned int TCFG1;
   volatile unsigned int TCON;
   volatile unsigned int TCNTB0;
   volatile unsigned int TCMPB0;
   volatile unsigned int TCNTO0;
   volatile unsigned int TCNTB1;
   volatile unsigned int TCMPB1;
   volatile unsigned int TCNTO1;
   volatile unsigned int TCNTB2;
   volatile unsigned int TCMPB2;
   volatile unsigned int TCNTO2;
   volatile unsigned int TCNTB3;
   volatile unsigned int TCMPB3;
   volatile unsigned int TCNTO3;
   volatile unsigned int TCNTB4;
   volatile unsigned int TCNTO4;
   volatile unsigned int TINT_CSTAT;
} pwm_t;

typedef enum {
    T0 = 0,
    T1,
    T2,
    T3,
    T4,
} timer_t;

typedef enum {
    OFF = 0,
    ON,
} switch_t;

typedef enum {
    T_ENABLE = 0,
    T_MANUAL,
    T_INVERTER,
    T_AUTO,
    T_DEAD_ZONE,
} optype_t;

typedef enum {
    TCFG0 = 1,
    TCFG1,
} tcfg_t;

#define PWM (*(pwm_t *)0xC0018000)

// PWM 配置
void hal_pwm_option(timer_t T, optype_t op, switch_t s);
// PWM 波形控制
void hal_pwm_waves(timer_t T, int tcntb, int tcmpb);


#endif
